package com.education.web.controller.course;

import java.util.List;
import javax.servlet.http.HttpServletResponse;

import com.education.course.domain.EduCourseSubjectTaskBind;
import com.education.course.service.IEduCourseSubjectTaskBindService;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.education.common.annotation.Log;
import com.education.common.core.controller.BaseController;
import com.education.common.core.domain.AjaxResult;
import com.education.common.enums.BusinessType; 
import com.education.common.utils.poi.ExcelUtil;
import com.education.common.core.page.TableDataInfo;

/**
 * 任务题目绑定Controller
 * 
 * @author education
 * @date 2024-08-07
 */
@RestController
@RequestMapping("/subject/task/bind")
public class EduCourseSubjectTaskBindController extends BaseController
{
    @Autowired
    private IEduCourseSubjectTaskBindService eduCourseSubjectTaskBindService;

    /**
     * 查询任务题目绑定列表
     */
    @PreAuthorize("@ss.hasPermi('system:bind:list')")
    @GetMapping("/list")
    public TableDataInfo list(EduCourseSubjectTaskBind eduCourseSubjectTaskBind)
    {
        startPage();
        List<EduCourseSubjectTaskBind> list = eduCourseSubjectTaskBindService.selectEduCourseSubjectTaskBindList(eduCourseSubjectTaskBind);
        return getDataTable(list);
    }

    /**
     * 导出任务题目绑定列表
     */
    @PreAuthorize("@ss.hasPermi('system:bind:export')")
    @Log(title = "任务题目绑定", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, EduCourseSubjectTaskBind eduCourseSubjectTaskBind)
    {
        List<EduCourseSubjectTaskBind> list = eduCourseSubjectTaskBindService.selectEduCourseSubjectTaskBindList(eduCourseSubjectTaskBind);
        ExcelUtil<EduCourseSubjectTaskBind> util = new ExcelUtil<EduCourseSubjectTaskBind>(EduCourseSubjectTaskBind.class);
        util.exportExcel(response, list, "任务题目绑定数据");
    }

    /**
     * 获取任务题目绑定详细信息
     */
    @PreAuthorize("@ss.hasPermi('system:bind:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(eduCourseSubjectTaskBindService.selectEduCourseSubjectTaskBindById(id));
    }

    /**
     * 新增任务题目绑定
     */
    @PreAuthorize("@ss.hasPermi('system:bind:add')")
    @Log(title = "任务题目绑定", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody EduCourseSubjectTaskBind eduCourseSubjectTaskBind)
    {
        return toAjax(eduCourseSubjectTaskBindService.insertEduCourseSubjectTaskBind(eduCourseSubjectTaskBind));
    }

    /**
     * 修改任务题目绑定
     */
    @PreAuthorize("@ss.hasPermi('system:bind:edit')")
    @Log(title = "任务题目绑定", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody EduCourseSubjectTaskBind eduCourseSubjectTaskBind)
    {
        return toAjax(eduCourseSubjectTaskBindService.updateEduCourseSubjectTaskBind(eduCourseSubjectTaskBind));
    }

    /**
     * 删除任务题目绑定
     */
    @PreAuthorize("@ss.hasPermi('system:bind:remove')")
    @Log(title = "任务题目绑定", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(eduCourseSubjectTaskBindService.deleteEduCourseSubjectTaskBindByIds(ids));
    }
}
